package com.fottas.adware.portal.controller;

import com.fottas.adware.common.api.CommonResult;
import com.fottas.adware.model.TmsTask;
import com.fottas.adware.model.TmsTaskCategory;
import com.fottas.adware.portal.domain.TaskAccordionResult;
import com.fottas.adware.portal.service.TaskService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@Api(tags = "TaskController", description = "任务管理")
@RequestMapping("/task")
public class TaskController {

    @Autowired
    private TaskService taskService;

    @ApiOperation("跳转发布任务")
    @RequestMapping(value="/toTask", method = RequestMethod.GET)
    @ResponseBody
    public CommonResult toTask() {

        //得到所有分类
        List<TmsTaskCategory> allTask = taskService.getAllTaskCategory();

        System.out.println(allTask);

        return CommonResult.success(allTask);
    }

    @ApiOperation("任务类别、来源")
    @RequestMapping(value="/accordion")
    @ResponseBody
    public CommonResult taskAccordion() {
        TaskAccordionResult accordion = taskService.accordion();
        return CommonResult.success(accordion);
    }

    @ApiOperation("任务添加")
    @RequestMapping(value="/add", method = RequestMethod.POST)
    @ResponseBody
    public CommonResult addTask() {

        return CommonResult.success(null,"132");
    }


    @ApiOperation("任务详情")
    @ResponseBody
    @RequestMapping(value="/taskDetail", method = RequestMethod.GET)
    public CommonResult taskDetail(TmsTask tmsTask) {
        Long id=1L;
        tmsTask=taskService.taskDetail(id);
        String a="123";
        System.out.println("aaaaaaaa");
        Map<String, Object> paramsMap = new HashMap<String, Object>();
        paramsMap.put("name","彭世蛟");
        paramsMap.put("age","22");
        return CommonResult.success(tmsTask,"132");
    }


}
